package models;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


import org.hibernate.validator.constraints.NotEmpty;

import com.avaje.ebean.Page;

import play.db.ebean.Model;
import play.db.ebean.Model.Finder;

@Entity
public class Disciplina extends Model{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public long id;

	@NotEmpty
	public String descricao;
	
	public static Finder<Long, Disciplina> find = new Finder<Long, Disciplina>(
			Long.class, Disciplina.class);

	public static Page<Disciplina> page(int page, int pageSize, String sortBy,
			String order, String filter) {
		return find.where().ilike("descricao", "%" + filter + "%")
				.orderBy(sortBy + " " + order)
				.findPagingList(pageSize).getPage(page);
	}
}
